<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="org.edu.system.DBConnect"%>
<%
	String stu_id = (String) (session.getAttribute("UserName"));
	String sql = "SELECT * FROM student WHERE stu_id = '" + stu_id + "'";
	System.out.println(sql);

	Connection con = DBConnect.getCon();
	Statement stmt = null;
	ResultSet rs = null;
	stmt = con.createStatement();
	rs = stmt.executeQuery(sql);//执行命令
	if (rs.next())// 如果记录集非空，表明有匹配的用户ID
	{

		//正常进行
	} else {
		// 否则登录失败
		// response.sendRedirect ( "MyJsp.jsp" );
		response.sendRedirect("login_failure.jsp");
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>课表查询</title>
</head>
<body style="width:900px; margin:0 auto;">
<br>
<div>
<form action="selectServlet" method=post>
<table>
	<tr>
		<td>学号：</td>
		<td><input type="text" name="stu_id" value=""></td>
		<td><input type="submit" name="sub" value="确定"></td>
	</tr>
</table>
</form>
<%
   // 重定向到新地址
   String site = new String("./selectServlet?stu_id="+stu_id);
   response.setStatus(response.SC_MOVED_TEMPORARILY);
   response.setHeader("Location", site); 
%>
</div>
</body>
</html>